package com.controller;

import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

import com.service.BaseManager;

public class OrgController extends UniversalController {
	private BaseManager baseManager;

	public BaseManager getBaseManager() {
		return baseManager;
	}

	public void setBaseManager(BaseManager baseManager) {
		this.baseManager = baseManager;
	}

	public ModelAndView getViewOrgTree(HttpServletRequest request,
			HttpServletResponse response) {
		return new ModelAndView("org");
	}

	/**
	 * Org
	 * **/
	public ModelAndView getListOrg(HttpServletRequest request,
			HttpServletResponse response) throws IllegalAccessException,
			InvocationTargetException {
		Map map = new HashMap();
		List list = null;
		list = baseManager.getListOrg();
		map.put("result", list);
		getMessage(response, getJsonFromJSONArray(map));
		return null;
	}

	/**
	 * Org
	 * **/
	public ModelAndView getListOrgTree(HttpServletRequest request,
			HttpServletResponse response) throws IllegalAccessException,
			InvocationTargetException {
		String code = request.getParameter("code");
		// Map map = new HashMap();
		List list = null;
		list = baseManager.getListOrgTreeByCode(code);
		// map.put("result", list);
		getMessage(response, getJsonFromJSONArray(list));
		return null;
	}
}
